package cn.lisens.config;

//import java.util.EnumSet;
//
//import javax.servlet.DispatcherType;
//import javax.servlet.FilterRegistration;
//import javax.servlet.ServletContext;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRegistration;
//
//import org.springframework.context.annotation.AnnotationConfigApplicationContext;
//import org.springframework.web.WebApplicationInitializer;
//import org.springframework.web.context.ContextLoaderListener;
//import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
//import org.springframework.web.filter.DelegatingFilterProxy;
//import org.springframework.web.servlet.DispatcherServlet;

public class AppInitializer 
//implements WebApplicationInitializer 
{
//
//	@Override
//	public void onStartup(ServletContext container) throws ServletException {
//		
//		AnnotationConfigWebApplicationContext context = getContext();
////        context.scan("cn.lisens");
//		container.addListener(new ContextLoaderListener(context));
//        
////        FilterRegistration.Dynamic shiroFilter = container.addFilter("shiroFilterFactoryBean", DelegatingFilterProxy.class);
//        FilterRegistration.Dynamic shiroFilter = container.addFilter("shiroFilterFactoryBean", DelegatingFilterProxy.class);
//        shiroFilter.setInitParameter("targetFilterLifecycle", "true");
//        EnumSet<DispatcherType> dispatcherTypes = EnumSet.noneOf(DispatcherType.class);
//        dispatcherTypes.add(DispatcherType.REQUEST);
//        dispatcherTypes.add(DispatcherType.FORWARD);
//        dispatcherTypes.add(DispatcherType.INCLUDE);
//        dispatcherTypes.add(DispatcherType.ERROR);
//        shiroFilter.addMappingForUrlPatterns(dispatcherTypes, false, "/*");
//        
//        
//		ServletRegistration.Dynamic registration = container.addServlet("DispatcherServlet", new DispatcherServlet(context));
//		registration.setLoadOnStartup(1);
//		registration.addMapping("/");
//	}
//
//	private AnnotationConfigWebApplicationContext getContext() {
//		AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
//		context.setConfigLocations(getClass().getPackage().getName());
//		return context;
//	}
}
